package dao.impl;

import javax.ejb.Stateless;
import javax.persistence.NoResultException;
import javax.persistence.Query;

import common.dao.impl.GenericJpaDAOImpl;

import dao.ProveedorDAO;
import entities.Proveedor;

@Stateless
public class ProveedorDAOBean extends GenericJpaDAOImpl<Proveedor> implements ProveedorDAO{

	@Override
	public Proveedor findByRazonSocial(String razonSocial) {
		Proveedor proveedor = null;
		try{
			Query query = this.entityManager.createQuery("SELECT p FROM Proveedor p WHERE p.razonSocial like '" + razonSocial + "' ");
			proveedor = (Proveedor) query.getSingleResult();
		}catch(NoResultException e){
			System.out.println(e.getMessage() + "Obtener proveeedor por razon social");
		}
		return proveedor;
	}

}
